── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.2 ✔ tibble 3.3.0
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ purrr::flatten() masks jsonlite::flatten()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Code
library(ggplot2)library(lubridate)library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:httr':
config
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
Code
library(scales)
Attaching package: 'scales'
The following object is masked from 'package:purrr':
discard
The following object is masked from 'package:readr':
col_factor
get data
Code
# Install if needed# install.packages(c("httr", "jsonlite"))# Calculate the date one week ago#since <- format(Sys.Date() - 30, "%Y-%m-%d")since <-"2024-01-01"# Query GitHub search API for repos created in the last week, ordered by starsres <-GET(url ="https://api.github.com/search/repositories",query =list(q =paste0("created:>", since),sort ="stars",order ="desc",per_page =20 ),add_headers(Accept ="application/vnd.github.v3+json"))stop_for_status(res)data <-content(res, as ="parsed", simplifyVector =TRUE)# Extract detailstop <- data$itemsdf <-data.frame(name = top$full_name,stars = top$stargazers_count,forks = top$forks_count,watchers = top$watchers_count,created_at = top$created_at,summary = top$description,url = top$html_url,stringsAsFactors =FALSE)glimpse(df)